//2009/08/16 00:46:30
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class BoxUnion
{
public:
    int area(vector <string> rect)
    {
        int sz = rect.size();
        if (sz == 1) return square(rect[0]);
        if (sz == 2) return square(rect[0]) + square(rect[1]) - square(intersect(rect[0], rect[1]));
        return square(rect[0]) + square(rect[1]) + square(rect[2]) - square(intersect(rect[0], rect[1])) - square(intersect(rect[0], rect[2])) - square(intersect(rect[2], rect[1])) + square(intersect(rect[0], intersect(rect[1], rect[2])));
    }
private:
    string intersect(string r1, string r2)
    {
        stringstream s1(r1);
        stringstream s2(r2);
        int a[4],b[4];
        s1 >> a[0] >> a[1] >> a[2] >> a[3];
        s2 >> b[0] >> b[1] >> b[2] >> b[3];
        int x1 = max(a[0],b[0]);
        int y1 = max(a[1],b[1]);
        int x2 = min(a[2],b[2]);
        int y2 = min(a[3],b[3]);
        if (x1 > x2 || y1 > y2) return "0 0 0 0";
        /*
		string s;
		s.clear();
		s += convertIntegerToString(x1);
		s += " " + convertIntegerToString(y1);
		s += " " + convertIntegerToString(x2);
		s += " " + convertIntegerToString(y2);
       cout << "s: " << s << endl;
       return s;
		*/
		stringstream s; char ch = ' ';
		s << x1 << ch << y1 << ch << x2 << ch << y2;
		cout << "s: " << s.str() << endl;
		return s.str();
    }
    int square(string r)
    {
        stringstream s(r);
        int a[4];
        s >> a[0] >> a[1] >> a[2] >> a[3];
        return (a[2] - a[0]) * (a[3] - a[1]);
    }
    string convertIntegerToString(int number)
    {
        stringstream s;			
        s << number;				
        return s.str();			
    }
};
